import * as Vrules from '@/util/validate';
let password = '';
let passwords = '';

let ISpassword = (rule, value, callback) => {
  password = value;
  // setTimeout(() => {
  //   if (password) {
  //     if (password != passwords) {
  //       callback(new Error("两次密码不一致!"));
  //     } else {
  //       callback();
  //     }
  //   } else {
  //     callback();
  //   }
  // }, 500);
};
let ISpasswords = (rule, value, callback) => {
  passwords = value;
  setTimeout(() => {
    if (password) {
      if (password != passwords) {
        callback(new Error("两次密码不一致!"));
      } else {
        callback();
      }
    } else {
      callback();
    }
  }, 500);
};

export const rules = {
  region: [
    { required: true, message: '请选择版本', trigger: 'change' }
  ],
  name: [
    { required: true, message: '请输入企业名称', trigger: 'change' },
    { min: 1, max: 25, message: '长度在 1 到 25 个字符', trigger: 'change' }
  ],
  phone: [
    { required: true, message: '请输入手机号', trigger: 'change' },
    { validator: Vrules.isPhone, trigger: 'change' }
  ],
  code: [
    { required: true, message: '请输入验证码', trigger: 'change' },
  ],
  password: [
    { required: true, message: '请输入密码', trigger: 'change' },
    // { validator: ISpassword, trigger: 'change' }
  ],
  passwords: [
    { required: true, message: '请再次输入密码', trigger: 'change' },
    // { validator: ISpasswords, trigger: 'change' }
  ],
  emall: [
    { required: true, message: '请输入邮箱', trigger: 'change' },
    { validator: Vrules.isEmail, trigger: 'change' }
  ],
  address: [
    { required: true, message: '请选择地址', trigger: 'change' }
  ]
};